////////////////////////////////////////////////////////
//	File : "BMPText.h"
//
//	Author : Matthew Canoy (MC)
//
//	Purpose : To Display BMP texteasily
////////////////////////////////////////////////////////

#pragma once 
#include <string>
#include <map>
#include "CSGD_Direct3D.h"
#include "TextureManager.h"
using std::string;
using std::map;

enum BITMAPFONTS
{
	NO_FONT = 0,
	BIG_FONT,
	LITTLE_FONT,
	TOTAL_FONTS
};

struct BMPFont
{
	int _nFontID;
	int _nImageID;
	int _nCharWidth;
	int _nCharHeight;
	int _nNumCols;
	char _startChar;

	BMPFont()
	{
		_nFontID = NO_FONT;
	}
};

class BMPText
{
	int m_nImageID;
	char m_startChar;
	int m_nCharWidth;
	int m_nCharHeight;
	int m_nNumCols;
	RECT GetRect(int index);
	RECT GetRectWithFont(int index, BMPFont* pFont);
	TextureManager* m_pTM;

	map<int, BMPFont*> m_mFonts;
///////////////////////////////////////////////////////
//
//	Necessary for a Singleton:
	BMPText(void);
	BMPText(BMPText &ref);
	BMPText &operator=(BMPText &ref);
	~BMPText();
public:

/////////////////////////////////////////////////////////////
// Function:	DrawBMPText
//
// Purpose:	Draws text based on the parameters passed in
/////////////////////////////////////////////////////////////
	void DrawBMPText(const char* szText, int nPosX, int nPosY, int nSpacing, DWORD dwColor, float fScale);
	void DrawBMPText(int nTextureID, const char* szText, int nPosX, int nPosY, int nSpacing, DWORD dwColor, float fScale);
	void DrawLimitedBMPText(int len, int nTextureID, const char* szText, int nPosX, int nPosY, int nSpacing, DWORD dwColor, float fScale);

	void DrawWithFont(int nFontID, const char* szText, int nPosX, int nPosY, DWORD dwColor = D3DCOLOR_XRGB(255,255,255), float fScale = 1.0f);
	void DrawWithFontLimitedText(int len, int nFontID, const char* szText, int nPosX, int nPosY, DWORD dwColor = D3DCOLOR_XRGB(255,255,255), float fScale = 1.0f);

/////////////////////////////////////////////////////////////
// Function:	SetBMPText
//
// Purpose:	Sets the singleton's font image to use
/////////////////////////////////////////////////////////////
	void SetBMPText(int bmp) {m_nImageID = bmp;}

/////////////////////////////////////////////////////////////
// Function:	BMPText
//
// Purpose:	Retrieves a single instance of the class 
/////////////////////////////////////////////////////////////
	static BMPText* GetInstance() { static BMPText instance; return &instance; }

/////////////////////////////////////////////////////////////
// Function:	SetStartChar
//
// Purpose:	Sets the start character of the class based on ASCII
/////////////////////////////////////////////////////////////
	void SetStartChar(char start) {m_startChar = start;}

	void InitFonts(char* _fileName);
	void Shutdown();
};